package com.ruiyi.subway.controller;

import com.ruiyi.subway.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;

@Api(value = "UserController", description = "普通用户相关接口")
@RestController
@RequestMapping("/user/")
public class UserController extends SupperController{

  @Autowired
  private IUserService iUserService;

    @ApiOperation(value = "获取所有的用户")
    @RequestMapping(value = "getUserList", method = RequestMethod.GET, produces = "application/json")
    public void getUserList(@RequestParam("page")  int page,
                            @RequestParam("rows") int rows,HttpServletResponse response) throws Exception {
            int start = (page - 1) * rows;
            HashMap<String,Object>hm=new HashMap<>();
            hm.put("start", start);
            hm.put("rows", rows);
            List<HashMap<String, Object>> list = iUserService.getUserList(hm);
            HashMap<String, Object> resultHm = new HashMap<String, Object>();
            resultHm.put("rows", list);
            outJsonForMap(resultHm, response);
    }

}
